#!/bin/sh

PATH=/usr/bin:/usr/sbin:/bin:/sbin

# the userPassword of dn: system-leave
systempass="adfasdtgerfgf" 				
systemleave="cn=admin,dc=nothing,dc=cn" 
accountleave="dc=nothing,dc=cn" 


ldappersonaldirs=$(
	ldapsearch -x -w $systempass -D "$systemleave"\
	-b "$accountleave" "(accountStatus=active)" \
	mailMessageStore | \
	grep "^[^#]" | grep mailMessageStore | \
	awk '{ print $2 }')

# create personal mailfolders

for ldappersonaldir in $ldappersonaldirs
do
        if [ ! -d $ldappersonaldir ]
        then
                mkdir -p `dirname $ldappersonaldir`
                maildirmake $ldappersonaldir
        fi
done

